﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AY38910
{
    using System.IO;

    class VtxFileReader : FileReader
    {
        public void Read(Stream stream)
        {
            stream.Position = 0;

            var fileHeader = new VtxFileHeader();
            fileHeader.Id = stream.ReadString(2);

            var validHeaders = new[] { "AY", "YM" };
            if (!validHeaders.Contains(fileHeader.Id.ToUpper()))
            {
                return;
            }

            if (fileHeader.Id.ToUpper() == "AY")
            {
                fileHeader.Mode = (byte)stream.ReadByte();
                fileHeader.UnpackSize = stream.ReadUInt32();
            }
            else
            {
                fileHeader.Mode = (byte)stream.ReadByte();
            }

            var songName = stream.ReadString();

        }
    }

    public class VtxFileHeader
    {
        public string Id { get; set; }

        public byte Mode { get; set; }

        public ushort Loop { get; set; }

        public uint ChipFrq { get; set; }

        public byte InterFrq { get; set; }

        public ushort Year { get; set; }

        public uint UnpackSize { get; set; }
    }
}
